home *** CD-ROM | disk | FTP | other *** search
- /* file meter.c
- shows meters that bounce up and down
- by LHL
- */
-
- #include "busybox.h"
-
- static int16 width, height, right, left, bottom, top;
- static int16 high1, high2, high3; /* how high the bar was last */
- static Rect meter1, meter2, meter3;
- static Rect barRect;
-
- void InitMeterObj(Rect *drawArea, int16 ID)
- {
- barRect = *drawArea;
- right = barRect.right;
- left = barRect.left;
- bottom = barRect.bottom;
- top = barRect.top;
- width = ((right - left) - 7) / 3;
- height = bottom - top;
- /* SetRect(&barRect, 0, 0, 500, 500); */
-
- SetRect(&meter1,left + 5, top + 2, (left + 2) + width, bottom - 2);
- SetRect(&meter2,meter1.right + 4, top + 2, meter1.right + width, bottom - 2);
- SetRect(&meter3,meter2.right + 4, top + 2, meter2.right + width, bottom - 2);
-
- } /* InitMeterObj */
-
-
- void DrawMeterObj(int16 ID)
- {
- static Rect OneUp, TwoUp, ThreeUp;
- int16 fudge1, fudge2, fudge3;
- static lastTime1, lastTime2, lastTime3;
-
- FrameRect(&meter1);
- FrameRect(&meter2);
- FrameRect(&meter3);
-
- fudge1 = abs(Random() % height) + 3;
- fudge2 = abs(Random() % height) + 3;
- fudge3 = abs(Random() % height) + 3;
-
- if (lastTime1 > fudge1) {
- SetRect(&OneUp, meter1.left + 1, fudge1, meter1.right - 1, meter1.bottom - 1);
- FillRect(&OneUp, gray);
- }
- else {
- SetRect(&OneUp, meter1.left + 1, lastTime1 - 1, meter1.right - 1, fudge1 - 1);
- FillRect(&OneUp, white);
- }
-
-
- if (lastTime2 > fudge2) {
- SetRect(&TwoUp, meter2.left + 1, fudge2, meter2.right - 1, meter2.bottom - 1);
- FillRect(&TwoUp, gray);
- }
- else {
- SetRect(&TwoUp, meter2.left + 1, lastTime2 - 1, meter2.right - 1, fudge2 - 1);
- FillRect(&TwoUp, white);
- }
-
-
- if (lastTime3 > fudge3) {
- SetRect(&ThreeUp, meter3.left + 1, fudge3, meter3.right - 1, meter3.bottom - 1);
- FillRect(&ThreeUp, gray);
- }
- else {
- SetRect(&ThreeUp, meter3.left + 1, lastTime3 - 1, meter3.right - 1, fudge3 - 1);
- FillRect(&ThreeUp, white);
- }
-
- lastTime1 = fudge1;
- lastTime2 = fudge2;
- lastTime3 = fudge3;
-
-
- } /* DrawMeterObj */
-